package com.baox.agridata.synchronous.schedule;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baox.agridata.synchronous.constant.*;
import com.baox.agridata.synchronous.entity.*;
import com.baox.agridata.synchronous.result.HttpResultResponse;
import com.baox.agridata.synchronous.result.Result;
import com.baox.agridata.synchronous.service.*;
import com.baox.agridata.synchronous.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.io.File;
import java.util.Date;
import java.util.List;

@Slf4j
@Component
public class SiChuanToChengDuBaseInfoSchedule {


    @Value("${TOCD.XDRCar}")
    private String XDRCarStartTime;   //车辆同步开始的时间


    @Value("${TOCD.XDRSlaughterHouse}")
    private String XDRSlaughterHouseStartTime;   //车辆同步开始的时间


    @Value("${TOCD.XDRHatchery}")
    private String XDRHatcheryStartTime;   //孵化场同步开始的时间


    @Value("${TOCD.XDRTrafficking}")
    private String XDRTraffickingStartTime;   //贩运户同步开始的时间


    @Value("${TOCD.XDRHarmless}")
    private String XDRHarmlessStartTime;   //无害化同步开始的时间


    @Value("${TOCD.XDRFarm}")
    private String XDRFarmStartTime;   //养殖场户同步开始的时间


    @Value("${TOCD.ZsEarTagRecordTime}")
    private String ZsEarTagRecordTime;   //耳标签发数据到成都的数据

    @Value("${TOCD.TBaseRegionStartTime}")
    private String TBaseRegionStartTime;   //四川更新的区划数据发送到成都


    @Value("${TOCD.TXDRLivestockMarketStartTime}")
    private String TXDRLivestockMarketStartTime;   //四川同步成都交易市场的数据


    @Autowired
    private TXDRCarService txdrCarService;  //车辆的service

    @Autowired
    private TXDRSlaughterHouseService txdrSlaughterHouseService;  //屠宰场的service

    @Autowired
    private TXDRLivestockMarketService txdrLivestockMarketService;  //交易场的service


    @Autowired
    private TXDRHatcheryService txdrHatcheryService; //孵化场的service


    @Autowired
    private TXDRTraffickingService txdrTraffickingService;  //贩运户的service


    @Autowired
    private TXDRHarmlessService txdrHarmlessService; //无害化的service

    @Autowired
    private TXDRFarmService txdrFarmService; //养殖场户的Service


    @Autowired
    private TZsApplyService tZsApplyService;  //追溯，任务详情同步到成都service

    @Autowired
    private TIMMUNEEarTagRecordService timmuneEarTagRecordService;  //zs_abp表中的数据，发送到成都

    @Autowired
    private ScAgricultureTaskService scAgricultureTaskService;


    @Autowired
    private TBaseRegionService tBaseRegionService;  //区划的service


    /**
     * 【车辆】同步：从四川同步到成都系统
     */
    @Async("newAsyncExecutor")
    @Scheduled(cron = "0 0/15 * * * ?")
    public void synchronizationTXDRCarToChengDu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_XDR_Car);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            try {
                Thread.sleep(1000); // 延迟1秒
                log.info("【四川同步成都:T_XDR_Car】,任务开始");
                FileUtil l_file = new FileUtil();
                String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "XDRCar";
                String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
                ///读取最后一次同步数据的时间
                if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                    XDRCarStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
                    if (StringUtils.isEmpty(XDRCarStartTime) || "null".equals(XDRCarStartTime)) {
                        XDRCarStartTime = DateUtil.jianFiveMinutes(nowTime);
                    }
                }
                List<TXDRCarEntity> l_list = txdrCarService.selectTXDRCarDataToChengDu(XDRCarStartTime);
                if (l_list != null && l_list.stream().count() > 0) {
                    String jsonData = JSON.toJSONString(l_list);
                    byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                    HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_Car, gzipData, HttpUtils.headers);  //发送网络请求
                    JSONObject jsonObject = JSON.parseObject(result.getBody());
                    Integer resultCode = jsonObject.getInteger("code");
                    if (resultCode.intValue() == Result.ok().getCode()) {  //当发送成功后，继续后续的操作
                        boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                        log.info("【四川同步成都:T_XDR_Car】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, XDRCarStartTime, nowTime, l_list.size());
                    } else {
                        log.info("【四川同步成都:T_XDR_Car】network error，时间节点为：{}---{}", XDRCarStartTime, nowTime);
                    }
                } else {
                    log.info("【四川同步成都:T_XDR_Car】本次发送四川未查询到数据，时间节点为：{}---{}", XDRCarStartTime, nowTime);
                    l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                }
            } catch (Exception e) {
                log.info("TXDRCar 出现了错误：" + e.getMessage());
            }
        } else {
            log.info("【四川同步成都:T_XDR_Car】同步任务未开启");
        }
    }


    /**
     * 【屠宰场】同步：从四川同步到成都系统
     */
    @Async("newAsyncExecutor")
    @Scheduled(cron = "0 0/30 * * * ?")
    public void synchronizationTXDRSlaughterHouseToChengDu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_XDR_SlaughterHouse);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            try {
                Thread.sleep(1000); // 延迟1秒
                log.info("【四川同步成都:T_XDR_SlaughterHouse】,任务开始");
                FileUtil l_file = new FileUtil();
                String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "XDRSlaughterHouse";
                String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
                if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                    XDRSlaughterHouseStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
                    if (StringUtils.isEmpty(XDRSlaughterHouseStartTime) || "null".equals(XDRSlaughterHouseStartTime)) {
                        XDRSlaughterHouseStartTime = DateUtil.jianFiveMinutes(nowTime);
                    }
                }
                List<TXDRSlaughterHouseEntity> l_list = txdrSlaughterHouseService.selectTXDRSlaughterDataToChengDu(XDRSlaughterHouseStartTime);
                if (l_list != null && l_list.stream().count() > 0) {
                    String jsonData = JSON.toJSONString(l_list);
                    byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                    HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_SlaughterHouse, gzipData, HttpUtils.headers);  //发送网络请求
                    JSONObject jsonObject = JSON.parseObject(result.getBody());
                    Integer resultCode = jsonObject.getInteger("code");
                    if (resultCode.intValue() == Result.ok().getCode()) {  //当发送成功后，继续后续的操作
                        boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                        log.info("【四川同步成都:T_XDR_SlaughterHouse】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, XDRSlaughterHouseStartTime, nowTime, l_list.size());
                    } else {
                        log.info("【四川同步成都:T_XDR_SlaughterHouse】network error，时间节点为：{}---{}", XDRSlaughterHouseStartTime, nowTime);
                    }
                } else {
                    log.info("【成都同步四川:T_XDR_SlaughterHouse】本次发送四川未查询到数据，时间节点为：{}---{}", XDRSlaughterHouseStartTime, nowTime);
                    l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                }
            } catch (Exception e) {
                log.info("TXDRSlaughterHouse 出现了错误：" + e.getMessage());
            }
        } else {
            log.info("【四川同步成都:T_XDR_SlaughterHouse】同步任务未开启");
        }
    }


    /**
     * 【贩运户】同步：从四川同步到成都系统
     */
    @Async("newAsyncExecutor")
    @Scheduled(cron = "0 0/15 * * * ?")
    public void synchronizationXDRTraffickingToChengDu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_XDR_Trafficking);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            try {
                Thread.sleep(1000); // 延迟1秒
                log.info("【四川同步成都:T_XDR_Trafficking】,任务开始");
                FileUtil l_file = new FileUtil();
                String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "XDRTrafficking";
                String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
                ///读取最后一次同步数据的时间
                if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                    XDRTraffickingStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
                    if (StringUtils.isEmpty(XDRTraffickingStartTime) || "null".equals(XDRTraffickingStartTime)) {
                        XDRTraffickingStartTime = DateUtil.jianFiveMinutes(nowTime);
                    }
                }
                List<TXDRTraffickingEntity> l_list = txdrTraffickingService.selectTXDRTraffickingDataToChengDu(XDRTraffickingStartTime);
                if (l_list != null && l_list.stream().count() > 0) {
                    String jsonData = JSON.toJSONString(l_list);
                    byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                    HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_Trafficking, gzipData, HttpUtils.headers);  //发送网络请求
                    JSONObject jsonObject = JSON.parseObject(result.getBody());
                    Integer resultCode = jsonObject.getInteger("code");
                    if (resultCode.intValue() == Result.ok().getCode()) {  //当发送成功后，继续后续的操作
                        boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                        log.info("【四川同步成都:T_XDR_Trafficking】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, XDRTraffickingStartTime, nowTime, l_list.size());
                    } else {
                        log.info("【四川同步成都:T_XDR_Trafficking】network error，时间节点为：{}---{}", XDRTraffickingStartTime, nowTime);
                    }
                } else {
                    log.info("【四川同步成都:T_XDR_Trafficking】本次发送四川未查询到数据，时间节点为：{}---{}", XDRTraffickingStartTime, nowTime);
                    l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                }
            } catch (Exception e) {
                log.info("TXDRTrafficking 出现了错误：" + e.getMessage());
            }
        } else {
            log.info("【四川同步成都:T_XDR_Trafficking】同步任务未开启");
        }
    }


    /**
     * 【养殖场】同步：从四川同步到成都系统
     */
    @Async("newAsyncExecutor")
    @Scheduled(cron = "0 0/10 * * * ?")
    public void synchronizationXDRFarmToChengDu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_XDR_Farm);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            try {
                Thread.sleep(1000); // 延迟1秒
                log.info("【四川同步成都:T_XDR_Farm】同步任务开始");
                FileUtil l_file = new FileUtil();
                String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "XDRFarm";
                String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
                ///读取最后一次同步数据的时间
                if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                    XDRFarmStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
                    if (StringUtils.isEmpty(XDRFarmStartTime) || "null".equals(XDRFarmStartTime)) {
                        XDRFarmStartTime = DateUtil.jianFiveMinutes(nowTime);
                    }
                }
                List<TXDRFarmEntity> l_list = txdrFarmService.selectTXDRFarmDataToChengDu(XDRFarmStartTime);
                if (l_list != null && l_list.stream().count() > 0) {
                    String jsonData = JSON.toJSONString(l_list);
                    byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                    HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_Farm, gzipData, HttpUtils.headers);  //发送网络请求
                    JSONObject jsonObject = JSON.parseObject(result.getBody());
                    Integer resultCode = jsonObject.getInteger("code");
                    if (resultCode.intValue() == Result.ok().getCode()) {  //当发送成功后，继续后续的操作
                        boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                        log.info("【四川同步成都:T_XDR_Farm】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, XDRFarmStartTime, nowTime, l_list.size());
                    } else {
                        log.info("【四川同步成都:T_XDR_Farm】network error，时间节点为：{}---{}", XDRFarmStartTime, nowTime);
                    }
                } else {
                    log.info("【四川同步成都:T_XDR_Farm】本次发送四川未查询到数据，时间节点为：{}---{}", XDRFarmStartTime, nowTime);
                    l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                }
            } catch (Exception e) {
                log.info("T_XDR_Farm 出现了错误：" + e.getMessage());
            }
        } else {
            log.info("【四川同步成都:T_XDR_Farm】同步任务未开启");
        }
    }

    /**
     * 区划数据每月更新
     */
    @Async("newAsyncExecutor")
    @Scheduled(cron = "0 20 12 2 * ?")
    public void synchronizationTBaseRegionToChengdu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_BASE_REGION);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            log.info("【四川同步成都:T_Base_Region】同步任务开始");
            FileUtil l_file = new FileUtil();
            String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "TBaseRegion";
            String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
            ///读取最后一次同步数据的时间
            if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                TBaseRegionStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
                if (StringUtils.isEmpty(TBaseRegionStartTime) || "null".equals(TBaseRegionStartTime)) {
                    TBaseRegionStartTime = DateUtil.jianFiveMinutes(nowTime);
                }
            }
            List<TBaseRegionEntity> l_list = tBaseRegionService.selectRegionToChengdu(TBaseRegionStartTime);
            if (l_list != null && l_list.stream().count() > 0) {
                String jsonData = JSON.toJSONString(l_list);
                byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                HttpUtils.post(HttpRequestUrl.T_BASE_REGION, gzipData, HttpUtils.headers);  //发送网络请求
            }
            boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
            log.info("【四川同步成都:T_Base_Region】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, TBaseRegionStartTime, nowTime, l_list.size());
        } else {
            log.info("【四川同步成都:T_Base_Region】同步任务未开启");
        }
    }

    /**
     * 动物交易市场数据
     */
    @Async("newAsyncExecutor")
    public void synchronizationTXDRLivestockMarketToChengdu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_XDR_LivestockMarket);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            log.info("【四川同步成都:T_XDR_LivestockMarket】同步任务开始");
            FileUtil l_file = new FileUtil();
            String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "TXDRLivestockMarket";
            String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
            ///读取最后一次同步数据的时间
            if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                TXDRLivestockMarketStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
            }
            List<TXDRLivestockMarketEntity> l_list = txdrLivestockMarketService.selectLivestockMarketToChengdu(TXDRLivestockMarketStartTime);
            if (l_list != null && l_list.stream().count() > 0) {
                String jsonData = JSON.toJSONString(l_list);
                byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                HttpUtils.post(HttpRequestUrl.T_XDR_LivestockMarket, gzipData, HttpUtils.headers);  //发送网络请求
            }
            boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
            log.info("【四川同步成都:T_XDR_LivestockMarket】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, TXDRLivestockMarketStartTime, nowTime, l_list.size());
        } else {
            log.info("【四川同步成都:T_XDR_LivestockMarket】同步任务未开启");
        }
    }


    /**
     * 耳标配送数据
     */
    @Async("newAsyncExecutor")
    @Scheduled(cron = "0 0 12 * * ?")
    public void synchronizationZsEarTagRecordToChengdu() {
        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_IMMUNE_EarTagRecord);
        if (sxAgricultureTask.getZt().intValue() == 1) {
            try {
                log.info("【四川同步成都:EarTagRecord】同步任务开始");
                FileUtil l_file = new FileUtil();
                String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "EarTagRecord";
                String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
                ///读取最后一次同步数据的时间
                if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
                    ZsEarTagRecordTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
                }
                List<TIMMUNEEarTagRecord> l_list = timmuneEarTagRecordService.selectIMMUNEEarTagRecordToChengdu(ZsEarTagRecordTime);
                if (l_list != null && l_list.stream().count() > 0) {
                    String jsonData = JSON.toJSONString(l_list);
                    byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
                    HttpResultResponse result = HttpUtils.post(HttpRequestUrl.EarTagRecord, gzipData, HttpUtils.headers);  //发送网络请求
                    JSONObject jsonObject = JSON.parseObject(result.getBody());
                    Integer resultCode = jsonObject.getInteger("code");
                    if (resultCode.intValue() == Result.ok().getCode()) {  //当发送成功后，继续后续的操作
                        boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                        log.info("【四川同步成都:EarTagRecord】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, ZsEarTagRecordTime, nowTime, l_list.size());
                    } else {
                        log.info("【四川同步成都:EarTagRecord】network error，时间节点为：{}---{}", ZsEarTagRecordTime, nowTime);
                    }
                } else {
                    log.info("【四川同步成都:EarTagRecord】本次未查询到数据，时间节点为：{}---{}", ZsEarTagRecordTime, nowTime);
                    l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
                }
            } catch (Exception e) {
                log.info("【四川同步成都:EarTagRecord】同步出现了异常");
                e.printStackTrace();
            }
        } else {
            log.info("【四川同步成都:EarTagRecord】同步任务未开启");
        }
    }


//    /**
//     * 这个方法就是临时同步四川到成都的数据
//     */
//    public void synchronizationXDRFarmToChengDu1() {
//        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_XDR_Farm);
//        if (sxAgricultureTask.getZt().intValue() == 1) {
//            List<TXDRFarmEntity> txdrFarmEntities = txdrFarmService.selectSichuanData();
//            if (txdrFarmEntities != null && txdrFarmEntities.size() > 0) {
//                String jsonData = JSON.toJSONString(txdrFarmEntities);
//                byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
//                HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_Farm_bak, gzipData, HttpUtils.headers);  //发送网络请求
//                JSONObject jsonObject = JSON.parseObject(result.getBody());
//                Integer resultCode = jsonObject.getInteger("code");
//                if (resultCode.intValue() == Result.ok().getCode()) {
//                    Integer integer = txdrFarmService.deleteFarmList(txdrFarmEntities);
//                    log.info("发送成功：" + integer);
//                } else {
//                    log.info("发送失败");
//                }
//            }
//        }
//    }
    //------------------------------------------------------上面是调好的----------------------------

//
//    /**
//     * 【孵化场】同步：从四川同步到成都系统
//     */
//    public void synchronizationTXDRHatcheryToChengDu() {
//        log.info("Starting Synchronous SiChuan To ChengDu【T_XDR_Hatchery】 Data !");
//        FileUtil l_file = new FileUtil();
//        String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "XDRHatchery";
//        ///读取最后一次同步数据的时间
//        if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
//            XDRHatcheryStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
//        }
//        List<TXDRHatcheryEntity> l_list = txdrHatcheryService.selectTXDRHatcheryDataToChengDu(XDRHatcheryStartTime);
//        String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
//        if (l_list != null && l_list.stream().count() > 0) {
//            String jsonData = JSON.toJSONString(l_list);
//            byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
//            HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_Hatchery, gzipData, HttpUtils.headers);  //发送网络请求
//            log.info("T_XDR_Hatchery request result====>" + result.getBody());
//            asyncLogOperationService.dealRequestResult(gzipData, TableNameConstant.T_XDR_Hatchery, result);  //异步处理返回的结果
//        }
//        //发送成功后，将新的时间重新写入文件中，下次读取
//        l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
//    }
//
//
//    /**
//     * 【无害化】同步：从四川同步到成都系统
//     */
//    public void synchronizationXDRHarmlessToChengDu() {
//        log.info("Starting Synchronous SiChuan To ChengDu【T_XDR_Harmless】 Data !");
//        FileUtil l_file = new FileUtil();
//        String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "XDRHarmless";
//        ///读取最后一次同步数据的时间
//        if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
//            XDRHarmlessStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
//        }
//        List<TXDRHarmlessEntity> l_list = txdrHarmlessService.selectTXDRHarmlessDataToChengDu(XDRHarmlessStartTime);
//        String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
//        if (l_list != null && l_list.stream().count() > 0) {
//            String jsonData = JSON.toJSONString(l_list);
//            byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
//            HttpResultResponse result = HttpUtils.post(HttpRequestUrl.XDR_Harmless, gzipData, HttpUtils.headers);  //发送网络请求
//            log.info("T_XDR_Harmless request result====>" + result.getBody());
//            asyncLogOperationService.dealRequestResult(gzipData, TableNameConstant.T_XDR_Harmless, result);  //异步处理返回的结果
//        }
//        //发送成功后，将新的时间重新写入文件中，下次读取
//        l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
//    }


    //    @Async("newAsyncExecutor")
//    @Scheduled(cron = "0 0 12 * * ?")
//    public void synchronizationZsApplyToChengDu() {
//        ScAgricultureTask sxAgricultureTask = scAgricultureTaskService.selectTaskStatus(TaskNameConstant.T_ZS_APPLY);
//        if (sxAgricultureTask.getZt().intValue() == 1) {
//            try {
//                Thread.sleep(1000); // 延迟1秒
//                log.info("【四川同步成都:T_ZS_APPLY】同步任务开始");
//                FileUtil l_file = new FileUtil();
//                String l_filePath = l_file.getPath() + File.separator + "TaskConfig" + File.separator + "ZSApply";
//                String nowTime = DateUtil.dateToMinute(new Date()) + ":00";
//                ///读取最后一次同步数据的时间
//                if (l_file.CheckFileExists(l_filePath, DataConstant.FILE_NAME)) {
//                    ZSAPPStartTime = l_file.readLastLineV2(l_filePath, DataConstant.FILE_NAME);
//                    if (StringUtils.isEmpty(ZSAPPStartTime) || "null".equals(ZSAPPStartTime)) {
//                        ZSAPPStartTime = DateUtil.jianFiveMinutes(nowTime);
//                    }
//                }
//                List<TZsApply> l_list = tZsApplyService.selectZsApplyChengduData(ZSAPPStartTime);
//                if (l_list != null && l_list.stream().count() > 0) {
//                    String jsonData = JSON.toJSONString(l_list);
//                    byte[] gzipData = GZIPUtils.compress(jsonData); //开始压缩
//                    HttpResultResponse result = HttpUtils.post(HttpRequestUrl.T_ZS_APPLY, gzipData, HttpUtils.headers);  //发送网络请求
//                    asyncLogOperationService.dealRequestResult(gzipData, TableNameConstant.T_ZS_APPLY, result);  //异步处理返回的结果
//                }
//                boolean timeCreateStatus = l_file.WriteContent(nowTime, l_filePath, DataConstant.FILE_NAME);
//                log.info("【四川同步成都:T_ZS_APPLY】文件记录生成状态：{},文件读取内容为：{},记录内容为：{},发送成都的条目数为：{}", timeCreateStatus, ZSAPPStartTime, nowTime, l_list.size());
//            } catch (Exception e) {
//                log.info("【四川同步成都:T_ZS_APPLY】同步出现了异常");
//                e.printStackTrace();
//            }
//        } else {
//            log.info("【四川同步成都:T_ZS_APPLY】同步任务未开启");
//        }
//    }
//
//

}
